#version 300 es
precision mediump float;
uniform sampler2D uTextureUnit;
in vec2 vTexCoord;

//输出
out vec4 vFragColor;

uniform float gamma;
uniform float contrast;
uniform float saturation;
uniform float brightness;
uniform float red;
uniform float green;
uniform float blue;
uniform float alpha;

void main(void)
{
     vec4 c = texture(uTextureUnit, vTexCoord);

     if (c.a > 0.0) {
          c.rgb /= c.a;

          vec3 rgb = pow(c.rgb, vec3(1. / gamma));
          rgb = mix(vec3(.5), mix(vec3(dot(vec3(.2125, .7154, .0721), rgb)), rgb, saturation), contrast);
          rgb.r *= red;
          rgb.g *= green;
          rgb.b *= blue;
          c.rgb = rgb * brightness;

          c.rgb *= c.a;
     }

     vFragColor = c * alpha;
}
